<template>
    <!-- <el-dialog :model-value="true"> -->
    <ReSelectForm v-model="state.value" :data="state.list" filterable label-prop="name" value-prop="id" allow-create multiple />
    <!-- </el-dialog> -->
    <div>
        <p>选中值：{{ state.value }}</p>
        <p>form select</p>
    </div>
</template>

<script lang="ts">
export default { name: 'SelectSearch' }
</script>

<script lang="ts" setup>
import { getCurrentInstance, ComponentInternalInstance, reactive, ref, nextTick, onMounted, useAttrs, useSlots } from 'vue'
import ReSelectForm from './ReSelectForm/index.vue'

// const slots = useSlots()
// const attrs = useAttrs()
// const emits = defineEmits()
const { proxy } = getCurrentInstance() as ComponentInternalInstance

const state = reactive({
    list: [
        {
            objState: 'N',
            code: 'hhhh3333',
            name: '对撞机',
            type: 3,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 7,
            format: null,
            id: 4,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-21 13:30:50',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-03',
            name: '测试机03',
            type: 3,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 13,
            format: null,
            id: 13,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-21 13:30:50',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-05',
            name: '测试机05',
            type: 2,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 15,
            format: null,
            id: 15,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-21 13:30:50',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-09',
            name: '测试机09',
            type: 3,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 19,
            format: null,
            id: 19,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-21 13:30:50',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-01',
            name: '测试机01',
            type: 1,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 11,
            format: null,
            id: 11,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-21 14:29:38',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-04',
            name: '测试机04',
            type: 1,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 14,
            format: null,
            id: 14,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 08:48:16',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-07',
            name: '测试机07',
            type: 1,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 17,
            format: null,
            id: 17,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 08:56:27',
            count: null,
        },
        {
            objState: 'N',
            code: 'abx',
            name: '测试仪器',
            type: 1,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 4,
            format: null,
            id: 3,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 09:31:16',
            count: null,
        },
        {
            objState: 'N',
            code: 'YQ23',
            name: '仪器23',
            type: 1,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 23,
            format: null,
            id: 36,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 09:31:16',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-02',
            name: '测试机02',
            type: 2,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 12,
            format: null,
            id: 12,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 11:10:48',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-06',
            name: '测试机06',
            type: 3,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 16,
            format: null,
            id: 16,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 13:25:05',
            count: null,
        },
        {
            objState: 'N',
            code: 'test-08',
            name: '测试机08',
            type: 2,
            duration: null,
            model: null,
            installDate: null,
            enableDate: null,
            repoPerson: null,
            repairPerson: null,
            repairTel: null,
            firm: null,
            sortNo: 18,
            format: null,
            id: 18,
            bid: null,
            state: null,
            cempId: null,
            ctime: null,
            uempId: null,
            utime: null,
            assignTime: '2022-09-22 13:25:05',
            count: null,
        },
    ],
    filterList: [] as any[],
    value: null,
})

// 默认筛选label跟inputCode

/**
 * 筛选函数，优先级最高
 * @param { string } value 输入的内容
 * @return { unknown[] } 返回一个由value值组成的数组，用于隐藏选项
 */
const filterMethod = (value:string):unknown[] => {
    if (!value) return []
    const hiddenlist = []
    state.list.forEach((item) => {
        if (item.name.indexOf(value) === -1) {
            // @ts-ignore
            hiddenlist.push(item.id)
        }
    })
    return hiddenlist
}

/**
* 筛选字段，优先级低于filterMethod
* @param { string[] } value 由字段组成的数组
*/
const filterProps = ['label', 'inputCode']

onMounted(() => {

})

// defineExpose({

// })
</script>
<style lang="scss" scoped>

</style>
